#include <ballade/network/ssl_context.h>

namespace Ballade
{
	namespace Network
	{
		
		SSLContext::SSLContext(Method method)
		{
			initialize(method);
		}
		
		SSLContext::~SSLContext()
		{
			SSL_CTX_free(_sslCtx);
		}
		
		SSL_CTX* SSLContext::getContext()
		{
			return _sslCtx;
		}
		
		void SSLContext::initialize(Method method)
		{
			SSLeay_add_ssl_algorithms();
			SSL_METHOD *meth;
			switch(method)
			{
			case TLSv2:
				meth = SSLv2_client_method();
			}
			_sslCtx = SSL_CTX_new(meth);
		}
	}
}